﻿using Microsoft.AspNetCore.Mvc;
using PowerHub.MES.Common.Utility;
using PowerHub.MES.DTO.BasicData.DTO;
using PowerHub.MES.DTO.BasicData.QueryDto;
using PowerHub.MES.DTO.Shopfloor.DTO;
using PowerHub.MES.DTO.Shopfloor.QueryDTO;
using PowerHub.MES.Entities.BasicData;
using PowerHub.MES.Entities.Shopfloor;
using PowerHub.MES.IServices.IBasic;
using PowerHub.MES.IServices.IShopfloor;
using PowerHub.MES.ReturnEntity;

namespace PowerHub.MES.Controllers.ProductionLine
{

    /// <summary>
    /// 产线管理
    /// </summary>
    [ApiController]
    [Route("Api/MES/Shopfloor/[controller]/[action]")]
    public class ProductionLineController
    {

        private IShopfloor_ProductionLineServices _shopfloor_ProductionLineServices;

        public ProductionLineController(IShopfloor_ProductionLineServices ProductionLineServices)
        {
            _shopfloor_ProductionLineServices = ProductionLineServices;
        }

        /// <summary>
        /// 获取产线列表
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("获取产线列表")]
        public async Task<OperationPageResult<List<Shopfloor_ProductionLine>>> GetShopfloor_ProductionLinePageListAsync([FromBody] QueryShopfloor_ProductionLineDTO pageQuery)
        {
            return await _shopfloor_ProductionLineServices.GetShopfloor_ProductionLinePageListAsync(pageQuery);
        }

        /// <summary>
        /// 根据产线Id获取产线工作站列表
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("根据产线Id获取产线工作站列表")]
        public async Task<OperationResult<List<Shopfloor_WorkStation>>> GetShopfloor_ProductionLineByIdWorkStationListAsync([FromBody] QueryShopfloor_ProductionLineDTO pageQuery)
        {
            return await _shopfloor_ProductionLineServices.GetShopfloor_ProductionLineByIdWorkStationListAsync(pageQuery);
        }


        /// <summary>
        /// 批量删除产线
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("批量删除产线")]
        public async Task<OperationResult<bool>> DeletionShopfloor_ProductionLineAsync([FromBody] List<string> Query)
        {
            return await _shopfloor_ProductionLineServices.DeletionShopfloor_ProductionLineAsync(Query);
        }

        /// <summary>
        /// 更新产线
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("更新产线")]
        public async Task<OperationResult<bool>> UpdateShopfloor_ProductionLineAsync([FromBody] Shopfloor_ProductionLineDTO Query)
        {
            return await _shopfloor_ProductionLineServices.UpdateShopfloor_ProductionLineAsync(Query);
        }

        /// <summary>
        /// 添加产线
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("添加产线")]
        public async Task<OperationResult<bool>> CreateShopfloor_ProductionLineAsync([FromBody] Shopfloor_ProductionLineDTO Query)
        {
            return await _shopfloor_ProductionLineServices.CreateShopfloor_ProductionLineAsync(Query);
        }
    }
}
